# $Id: PKGBUILD 65942 2012-02-22 13:52:17Z spupykin $
# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>

pkgname=perl-test-number-delta
_realname=Test-Number-Delta
pkgver=1.03
pkgrel=2
pkgdesc="Compare the difference between numbers against a given tolerance"
arch=(any)
license=('PerlArtistic')
url="http://search.cpan.org/~dagolden/Test-Number-Delta"
options=(!emptydirs)
depends=('perl')
provides=("test-number-delta=$pkgver" "Test::Number::Delta=$pkgver" "perl-test-number-delta=$pkgver")
source=(http://search.cpan.org/CPAN/authors/id/D/DA/DAGOLDEN/Test-Number-Delta-$pkgver.tar.gz)
md5sums=('17d3eec2d5bbe012c4a797af8e75ae39')

build() {
  _expected_dir="${srcdir}/${_realname}-${pkgver}"
  if [ -d "$_expected_dir" ]; then
    cd "$_expected_dir"
  else
    _expected_dir="${srcdir}/$(bsdtar -t -f $(basename $source) | head -n1)"
    if [ -d "$_expected_dir" ]; then
      cd "$_expected_dir"
    else
      _makefile=$(find $srcdir -iname Makefile.PL)
      if [ ! -z "$_makefile" ]; then
        _expected_dir=$(dirname $_makefile)
        if [ -d "$_expected_dir" ]; then
          cd "$_expected_dir"
        else
          echo "[1;31mERROR[0m unable to detect source directory"
          echo "[1;34m-->[0m this is often due to CPAN's lack of standard naming conventions"
          echo "[1;34m-->[0m it may be possible to fix this by adjusting the build function in the PKGBUILD"
        fi
      fi
    fi
  fi
  # install module in vendor directories.
  PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor
  make
  make install DESTDIR=${pkgdir}

  # remove perllocal.pod and .packlist
  find ${pkgdir} -name perllocal.pod -delete
  find ${pkgdir} -name .packlist -delete
}
